<?php

/* 
 * 内容
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
class storyContentModel extends db_help
{
    public $keyFields = 'cid';//设置主键
    public function __construct() {
        parent::__construct();
        $this->table_name = $this->table('story_content');
    }
    public static function load(){
        return new self();
    }
    /**
     * 
     * @param type $tid
     * @return type
     */
    public function getTid($tid) {
        $where = array(
            'tid' => $tid,
        );
        return $this->getOne('tid', $where);
    }
    /**
     * 
     * @param type $tid
     * @param type $id
     * @return type
     */
    public function getReplyId($tid, $id) {
        $where = array(
            'tid' => $tid,
            'replyid' => $id,
        );
        return $this->getOne('replyid', $where);
    }
    /**
     * 获取内容
     * @param type $tid
     * @return type
     */
    public function getContent($tid) {
        $sql = "select content from {$this->table_name} where tid = '{$tid}' order by floor";
        return $this->result_array($sql);
    }
    /**
     * 
     * @param type $cid
     * @return type
     */
    public function get_info($cid) {
        $where = array(
            'cid' => $cid,
        );
        return $this->getRow(null, $where);
    }
    /**
     * 更新字段content
     * @param type $cid
     * @param type $content
     * @return type
     */
    public function updateContent($cid, $content) {
        $data = array(
            'content' => $content,
            'ltime' => time(),
        );
        $where = array(
            'cid' => $cid,
        );
        return $this->update($data, $where);
    }
}

